#!/bin/bash
#

date=$(date +%s)
date_ago=$(date -d "3 days ago" +%s)
log="/opt/test"
cd $log

for file in *.log;do
  file_time=$(stat -c %Y "$file")
   if [[ "$file_time" < "$date_ago" ]];then
    echo "删除三天前的文件：$file"
    rm -rf "$file"
   fi
done

echo "日志文件已清理" 
